package org.springblade.modules.ad.entity;

import com.google.common.collect.Lists;
import lombok.Data;
import lombok.ToString;
import org.springblade.core.tool.utils.CollectionUtil;

import java.util.LinkedList;
import java.util.List;
import java.util.stream.Collectors;

/**
 * ou 对象
 * @ClassName AdOrganizationalUnit.java
 * @version 1.0.0
 * @author zhangyunjiao
 * @createTime 2021/8/25
 */
@Data
@ToString
public class AdOU {


	/**
	 * 创建的OU 名称
	 */
	private String name;

	/**
	 * 描述
	 */
	private String description;

	/**
	 * ou 路径
	 */
	private LinkedList<String> basePath;

	/**
	 * 子节点
	 */
	private List<AdOU> children;

	/**
	 * 部门ID
	 */
	private Long deptId;

	/**
	 * 用户
	 */
	private List<AdUser> userList;



	private List<String> members;

	public List<String> getMembers() {
		if (CollectionUtil.isNotEmpty(userList)) {
			return userList.stream().map(AdUser::getGivenName).collect(Collectors.toList());
		}
		return Lists.newArrayList();
	}
}
